package org.example.xml;

/**
 * @author scout.du
 * @date 2025/10/17 14:48
 **/
public class Start {

//    public static void main(String[] args) throws DocumentException {
//
//        String xml = """
//               <?xml version="1.0" encoding="utf-8"?>
//               <notification>
//                 <servicedata>
//                   <fbdKeyValueNotificationServiceData>
//                     <parameter>
//                       <name>VIN</name>
//                       <value>{vin}</value>
//                     </parameter>
//                     <parameter>
//                       <name>FriendlyName</name>
//                       <value>{friendlyName}</value>
//                     </parameter>
//                   </fbdKeyValueNotificationServiceData>
//                 </servicedata>
//               </notification>
//                """;
//        Document doc = DocumentHelper.parseText(xml);
//
//        Element root = doc.getRootElement();
//        List<Element> elements = root.element("servicedata").element("fbdKeyValueNotificationServiceData").elements("parameter");
//        String value1 = elements.get(0).element("value").getText();
//        String value2 = elements.get(1).element("value").getText();
//        System.out.println(value1);
//        System.out.println(value2);
//
//        // 方式 1：使用 DocumentHelper.parseText()
////        Document doc = DocumentHelper.parseText(xml);
////
////        Element root = doc.getRootElement();
////        List<Element> elements = root.element("servicedata").element("fbdKeyValueNotificationServiceData").elements("parameter");
////        Element name = elements.get(0).element("name");
////        System.out.println(name.getName());
////        System.out.println(name.getText());
////
////        Element value = elements.get(0).element("value");
////        System.out.println(value.getName());
////        System.out.println(value.getText());
////
////        System.out.println(elements.get(0).getName());
////
////        String text = elements.get(0).getText();
////        System.out.println(text);
////
////        String stringValue = elements.get(0).getStringValue();
////        System.out.println(stringValue);
////        Element servicedata = root.element("servicedata");
////        System.out.println(servicedata.getName());
////        List<Attribute> list = root.element("fbdKeyValueNotificationServiceData").attributes();
////        System.out.println(list.size());
//        //        root.element()
////        System.out.println(root.element("name").getText()); // 输出：Du Scout
//    }
}
